function load_project_name(name)
{

	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
										{
											if (xmlhttp.readyState==4 && xmlhttp.status==200)
											{
												document.getElementById("pn").innerHTML=name;
											}
										}
}


function load_project(id)
{

	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
										{
											if (xmlhttp.readyState==4 && xmlhttp.status==200)
											{
												document.getElementById("project_name").innerHTML=xmlhttp.responseText;
											}
										}
	xmlhttp.open("GET","../DATA/load_project.php?id="+id,true);
	xmlhttp.send();

}

function load_project_sort_by(id,sort,field)
{

	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
										{
											if (xmlhttp.readyState==4 && xmlhttp.status==200)
											{
											document.getElementById("project_name").innerHTML=xmlhttp.responseText;
											}
										}
	xmlhttp.open("GET","../DATA/load_project.php?id="+id+"&sort="+sort+"&field="+field,true);
	xmlhttp.send();
}

function load_project_sort_by_at_bug_id(id,searchbugid)
{

	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
										{
											if (xmlhttp.readyState==4 && xmlhttp.status==200)
											{
											    document.getElementById("project_name").innerHTML=xmlhttp.responseText;
											}
										}
	xmlhttp.open("GET","../DATA/load_project.php?id="+id+"&searchbugid="+searchbugid,true);
	xmlhttp.send();
}

function searchbug()
{
	var bug_id = document.getElementById('txtsearch').value;
	var current_project_id = document.getElementById('project').value;
	//alert("../DATA/load_project.php?id="+current_project_id+"&search_bug_id="+bug_id);
	//alert( current_project_id + bug_id);
	load_project_sort_by_at_bug_id(current_project_id,bug_id);
	
}

function load_frmAddBug()
{
	window.location.href = "frmAddBug.php";
}

function addcomment(bug_id,textbox_id,project_id,event)
{
    if (event.keyCode == 13  || event.which == 13) 
    {
       var content = document.getElementById(textbox_id).value;
       if(content != '')
       {
            xmlhttp.open("GET","../DATA/load_project.php?id="+project_id+"&bug_id_add_comment="+bug_id+"&content="+content,true);
	        xmlhttp.send();
            document.getElementById(textbox_id).value = '';
       }

    }
    
}

function change_bug_status(project_id,bug_id_change,status_changed,dropdown_status_id)
{
    document.getElementById(dropdown_status_id).style.display = 'none';
    xmlhttp.open("GET","../DATA/load_project.php?id="+project_id+"&bug_id_change="+bug_id_change+"&status_changed="+status_changed,true);
	xmlhttp.send();
}